﻿using NetWing.BPM.Admin.weixin;
using NetWing.Common;
using NetWing.Common.Data.SqlServer;
using NetWing.Model;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.DynamicData;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NetWing.BPM.Admin.JydModleOrder
{
    public partial class myOrder : System.Web.UI.Page
    {
        public DataTable dw = null;
        public DataTable de = null;
        protected string sta;
        public DataTable zt = null;


        protected ArrayList values = new ArrayList();

        protected void Page_Load(object sender, EventArgs e)
        {
            string reurl = Request.Url.ToString();//获取当前url
            CookieHelper.WriteCookie("returnurl", reurl);//把返回信息写入cookies
            bool r = wxhelper.checkLogin();//wxhelper.checkLogin() 该函数会自动去获得用户openid 获得openid后需要返回当前入口页面 reurl 就是获得openid后的入口页面
            string kk = "";
            string openidde = CookieHelper.GetCookie("openid"); 
            string sql = "select tell from jydUser where OpenID='" + openidde + "' and tell<>'' ";
            DataRow dr = SqlEasy.ExecuteDataRow(sql);
            //if(dr == null) { 
            //Context.Response.End("<script>alert('手机绑定之后才可进行查询订单');location.href='http://szh.s3.natapp.cc/weixin/bindyg.aspx';</script>");
            //}
            //else
            //{
            //    de = SqlEasy.ExecuteDataTable("select orderid from jydOrder where tel='" + dr["tell"].ToString() + "' group by orderid order by orderid desc");
            //}
            if (dr == null)
            {

            }
            else
            {
                string sqlyi = "select orderid from jydOrder where tel='" + dr["tell"].ToString() + "' group by orderid order by orderid desc";
                de = SqlEasy.ExecuteDataTable(sqlyi);

                 zt = SqlEasy.ExecuteDataTable("select * from jydOrder where tel='" + dr["tell"].ToString() + "' order by orderid desc");
                foreach (DataRow ztt in zt.Rows)
                {
                    if (zt.Rows.Count > 0)
                    {
                        sta = zt.Rows[0]["status"].ToString();
                    }
                }


                foreach (DataRow drw in de.Rows)
                {
                    string[] odArr = drw["orderid"].ToString().Split('-');
                    if (odArr.Length == 4)
                    {
                        dw = SqlEasy.ExecuteDataTable("select yspmc,orderid from jydOrderDetail where orderid='" + drw["orderid"].ToString() + "' order by KeyId desc");
                        for (int i = 0; i < dw.Rows.Count; i++)
                        {
                            values.Add(dw.Rows[i]["yspmc"].ToString() + "," + dw.Rows[i]["orderid"].ToString());
                        }
                    }
                }
            }
            


            



           





        }
    }
}